﻿using UnityEngine;
using System.Collections;

public class FX_setDissolveShader : MonoBehaviour {

	public float dissolveSpeed = 0.1f;
	public float fOffsetTime = 1f;
	float sliceAmount;
	bool dissolve = false;
	// Use this for initialization
	void Awake () {
		Invoke ("DissolveActive", fOffsetTime);
	}
	
	// Update is called once per frame
	void Update () {
		if(dissolve){
			sliceAmount -= Time.deltaTime * dissolveSpeed;
			transform.renderer.material.SetFloat("_DissolvePower", 0.65f + Mathf.Sin(0.9f)*sliceAmount);
			if(renderer.material.GetFloat("_DissolvePower") < 0.1f)
				dissolve = false;
		}
	}

	void DissolveActive(){
		dissolve = true;
	}
}
